package com.ruoyi.web.controller.staffing;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.staffing.domain.HrCandidate;
import com.ruoyi.staffing.service.IHrCandidateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * HR-候选人(求职登记)主Controller
 * 
 * @author ruoyi
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/staffing/candidate")
public class HrCandidateController extends BaseController
{
    @Autowired
    private IHrCandidateService hrCandidateService;

    /**
     * 查询HR-候选人(求职登记)主列表
     */
    @PreAuthorize("@ss.hasPermi('staffing:candidate:list')")
    @GetMapping("/list")
    public TableDataInfo list(HrCandidate hrCandidate)
    {
        startPage();


        List<HrCandidate> list = hrCandidateService.selectHrCandidateList(hrCandidate);
        return getDataTable(list);
    }

    /**
     * 导出HR-候选人(求职登记)主列表
     */
    @PreAuthorize("@ss.hasPermi('staffing:candidate:export')")
    @Log(title = "HR-候选人(求职登记)主", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HrCandidate hrCandidate)
    {
        List<HrCandidate> list = hrCandidateService.selectHrCandidateList(hrCandidate);
        ExcelUtil<HrCandidate> util = new ExcelUtil<HrCandidate>(HrCandidate.class);
        util.exportExcel(response, list, "HR-候选人(求职登记)主数据");
    }

    /**
     * 获取HR-候选人(求职登记)主详细信息
     */
    @PreAuthorize("@ss.hasPermi('staffing:candidate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hrCandidateService.selectHrCandidateById(id));
    }

    /**
     * 新增HR-候选人(求职登记)主
     */
    @PreAuthorize("@ss.hasPermi('staffing:candidate:add')")
    @Log(title = "HR-候选人(求职登记)主", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HrCandidate hrCandidate)
    {


        logger.info("入参：{}",hrCandidate);
        return toAjax(hrCandidateService.insertHrCandidate(hrCandidate));
    }

    /**
     * 修改HR-候选人(求职登记)主
     */
    @PreAuthorize("@ss.hasPermi('staffing:candidate:edit')")
    @Log(title = "HR-候选人(求职登记)主", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HrCandidate hrCandidate)
    {
        return toAjax(hrCandidateService.updateHrCandidate(hrCandidate));
    }

    /**
     * 删除HR-候选人(求职登记)主
     */
    @PreAuthorize("@ss.hasPermi('staffing:candidate:remove')")
    @Log(title = "HR-候选人(求职登记)主", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hrCandidateService.deleteHrCandidateByIds(ids));
    }
}
